package com.zds.support.adapter


import android.content.Context
import android.content.res.Resources
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.RecyclerView
import com.zds.support.util.FastClickUtils
import com.zds.support.util.ViewUtils

/**
 * Created by zc
 */
abstract class BaseViewHolder : RecyclerView.ViewHolder, View.OnClickListener {
    protected val mResources: Resources
    protected val mContext: Context
    protected val mOnClickListener: View.OnClickListener

    constructor(context: Context, view: View)
            : super(view) {

        mContext = context
        mResources = mContext.resources
        mOnClickListener = this

        /*RxBus.observe<ConfigurationChangedEvent>().registerInBus({ event: ConfigurationChangedEvent ->
            //   recreate()
            Log.d("设置语言","首页语言-》"+mResources.configuration.locale.displayLanguage)
            mResources.updateConfiguration(event.config,mResources.displayMetrics)
            Log.d("设置语言","首页语言-》"+mResources.configuration.locale.displayLanguage)


        }, AndroidSchedulers.mainThread(), null, this)*/
    }

    constructor(context: Context, parent: ViewGroup?, @LayoutRes layoutId: Int)
            : this(context, ViewUtils.getView(context, parent, layoutId, false)) {

    }


    open fun onViewClick(v: View) {}

    final override fun onClick(v: View?) {
        if (v != null && !FastClickUtils.isFastClick()) {
            onViewClick(v)
        }
    }
}